<script>
import * as echarts from 'echarts'
export default {
  data() {
    return {
      name: "张雪",
      xData: ["2020-02", "2020-03", "2020-04", "2020-05"], //横坐标数据
      yData: [30, 132, 80, 134] //纵坐标数据，与横坐标对应
    };
  },
  mounted() {
    this.initEcharts();
  },
  methods: {
    initEcharts() {
      const option = {
        title: {
          text: "课堂参与度变化曲线"
        },
        tooltip: {},
        legend: {
          data: ["注意力"]
        },
        xAxis: {
          type: "category",
          data: ["9:00", "9:05", "9:10", "9:15", "9:20", "9:25"]
        },
        yAxis: {},
        series: [
          {
            name: "销量",
            type: "line",
            data: [5, 20, 36, 10, 10, 20]
          }
        ]
      };
      const myChart = echarts.init(this.$refs.mychart);// 图标初始化
      myChart.setOption(option);// 渲染页面
      //随着屏幕大小调节图表
      window.addEventListener("resize", () => {
        myChart.resize();
      });
    }
  }
}
</script>

<template>
  <div
    class="echart"
    ref="mychart"
    id="mychart"
    :style="{ float: 'left', width: '100%', height: '180px' }"
  ></div>
</template>

<style scoped>

</style>
